import vue from '../main'
import store from '../store/index';
import { Loading  } from 'element-ui';
import { OBJ } from './init'

/**
 * 显示更新模态框
 * flag :true显示  :false隐藏
 * **/
export function showUpdate(flag){
    if(flag){
        store.commit('switchUpdate', true);
    }else{
        store.commit('switchUpdate', false);
    }
}

/**
 * 提交更新
 * **/
export function submitupdate(type, info) {
    Loading.service({
        text: vue.$t("loading")
    })
    switch (type) {
        case 'online':
            var msg = new ROSLIB.Message({
                seq: 1,
                frame_id: "update_request"
            });
            OBJ.topic.taskSwitchTopic.publish(msg);
            break;
        default:
            console.error(`[ERROR]unknown update mode: ${type}`);
            break;
    }
};